import 'package:flutter/material.dart';

void main() {
  runApp(new MyStateLessWidget());
}

class MyStateLessWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: "TestDart",
      theme: new ThemeData(primaryColor: Colors.black),
      home: new MyStateFulWidget(),
    );
  }
}

class MyStateFulWidget extends StatefulWidget {
  @override
  MyState createState() => new MyState();
}

class MyState extends State<MyStateFulWidget> with TickerProviderStateMixin {
  AnimationController controller;
  CurvedAnimation curve;

  @override
  void initState() {
    controller = new AnimationController(
        duration: const Duration(milliseconds: 2000), vsync: this);
    curve = new CurvedAnimation(parent: controller, curve: Curves.easeOut);
  }

  String textToShow = "first flutter widget";

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("Sample MyState"),
      ),
      body: new Center(
          child: new Container(
              child: new FadeTransition(
                opacity: curve,
                child: new CustomButton("Hello")
      ))),
      floatingActionButton: new FloatingActionButton(
        onPressed: () {
          controller.forward();
        },
        tooltip: "Fade",
        child: new Icon(Icons.update),
      ),
    );
  }
}

class CustomButton extends StatelessWidget {
  final String label;

  CustomButton(this.label);

  @override
  Widget build(BuildContext context) {
    return new RaisedButton(
      onPressed: () {},
      child: new Text(label),
    );
  }
}
